<template>
	<div class="risk">
		<van-search
			class="info_search"
			@search="onSearch"
			@clear="clearSearch"
			v-model="value"
			placeholder="搜索"
		/>
		<van-list
			style="margin-top: 10px"
			:finished="finished"
			v-model="loading"
			@load="onLoad"
			finished-text="没有更多了"
		>
			<div v-for="(item, index) in list" :key="index">
				<div class="risk_item_list" @click="chooseExam(item)">
					<div class="mb-10 exam-hd">{{ item.PaperName }}</div>
					<div class="exam-bd">
						<div>包含试题提数：{{ item.TotalQuestions }}</div>
						<div>总分：{{ item.TotalScore || 0 }}分</div>
						<div>及格：{{ item.EvaluationValue || 0 }}分</div>
					</div>
				</div>
			</div>
		</van-list>
	</div>
</template>

<script>
import { getExamList } from '@/api/addexam'
export default {
	data() {
		return {
			list: [],
			userlist: [],
			result: [],
			loading: false,
			finished: false,
			filter: {
				page: 0,
				dataType: 'Window',
				keywords: '',
			},
			activeNames: ['1'],
			border: false,
			value: '',
			radio: '',
		}
	},
	created() {
		this.getList()
	},
	methods: {
		onSearch() {
			this.filter.page = 0
			this.filter.keywords = this.value
			this.getList()
		},
		clearSearch() {
			this.filter.page = 0
			this.filter.keywords = ''
			this.getList()
		},
		onLoad() {
			this.loading = true
			++this.filter.page
			getExamList(this.filter).then((res) => {
				this.loading = false
				this.filter.page = res.data.PageIndex
				this.list = this.list.concat(res.data.Data)
				if (!res.data.HasNextPage) {
					this.finished = true
				}
			})
		},
		getList() {
			this.loading = true
			getExamList(this.filter)
				.then((res) => {
					this.loading = false
					if (!res.data.HasNextPage) {
						this.finished = true
					}
					this.list = res.data.Data
					this.filter.page = res.data.PageIndex
				})
				.catch((err) => {
					console.log('err', err)
				})
		},

		checkAll() {
			this.$refs.checkboxGroup.toggleAll(true)
		},
		toggleAll() {
			this.$refs.checkboxGroup.toggleAll(false)
		},
		// 确认
		chooseExam(item) {
			// this.$router.push({
			// 	name: 'AddExam',
			// 	params: { examData: item },
			// })
			// 	this.$router.push({
			// 	name: this.$route.params.path,
			// 	params: { examData: item },
			// })

			this.$emit('cb', item)
		},
	},
}
</script>
<style lang="less">
.info_search {
	padding: 10px;
	border-radius: 5px !important;
	.van-field__control {
		background-color: #ffffff !important;
	}
}
</style>
<style lang="less" scoped>
.risk {
	height: 100vh;
	background-color: #e8f1f8;

	.info_search {
		padding: 10px;
		border-radius: 5px !important;

		.van-field__control {
			background-color: #ffffff !important;
		}
	}
}

.risk_item_list {
	width: 100%;
	padding: 10px 20px;
	background-color: #fff;
	font-size: 14px;
	border-bottom: 1px solid #e8f1f8;
}

.exam-hd {
	font-size: 15px;
}
.exam-bd {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: #666;
	font-size: 12px;
}
</style>
